import { createBrowserRouter } from "react-router-dom";
import App from "../views/App";

// react里面要实现路由的懒加载，需要使用到 React.lazy()
import { lazy } from "react";

// import Fast from "../views/Fast";
// import Home from "../views/Home";
import Login from "../views/Login";
// import Mine from "../views/Mine";
// import Practice from "../views/Practice";
// import Select from "../views/Select";
// import Sbujects from "../views/Subjects";

const Home = lazy(() => import("../views/Home"));
const Fast = lazy(() => import("../views/Fast"));
const Mine = lazy(() => import("../views/Mine"));
const Practice = lazy(() => import("../views/Practice"));
const Select = lazy(() => import("../views/Select"));
const Subjects = lazy(() => import("../views/Subjects"));
// 创建路由对象
const router = createBrowserRouter([
  {
    path: "/login",
    element: <Login />,
  },
  {
    // 我们要在这个页面里面进行路由拦截，判断是否登录
    path: "/",
    element: <App />,
    children: [
      {
        path: "home",
        // index: true,
        element: <Home />,
      },
      {
        path: "fast",
        element: <Fast />,
      },
      {
        path: "mine",
        element: <Mine />,
      },
      {
        path: "select/:code",
        element: <Select />,
      },
      {
        path: "practice",
        element: <Practice />,
      },
      {
        path: "subjects",
        element: <Subjects />,
      },
    ],
  },
]);

export default router;
